﻿#region imports

using System.Collections.Generic;
using System.Linq;
using Codeplex.ODataTFS.Model.Entities;
using Codeplex.ODataTFS.Model.Serialization;
using Microsoft.Data.Services.Toolkit.QueryModel;

#endregion

namespace Codeplex.ODataTFS.Model.Repositories
{
	public class AreaPathRepository : IODataRepository<AreaPath>
	{
		private readonly TFSAreaPathProxy _proxy;

		public AreaPathRepository(TFSAreaPathProxy proxy)
		{
			_proxy = proxy;
		}

		public AreaPath GetOne(string path)
		{
			return _proxy.GetAllAreaPaths().SingleOrDefault(a => a.Path.Equals(path));
		}

		public IEnumerable<AreaPath> GetAll(ODataQueryOperation operation)
		{
			return _proxy.GetAllAreaPaths();
		}

		public IEnumerable<AreaPath> GetSubAreasByAreaPath(string path)
		{
			return _proxy.GetSubAreas(path);
		}

		public IEnumerable<AreaPath> GetAreaPathsByProject(string projectName)
		{
			return _proxy.GetAreaPathsByProject(projectName);
		}
	}
}
